
SettingsCtrl.$inject = ['$scope', '$location',
                        'SettingsGetAll'];

function SettingsCtrl($scope,  $location, SettingsGetAll) {
  
  // Get recent activities
    SettingsGetAll.get( { limit: 30},  function(data) {
       if (data.result.status == "ok")
       {
          
          $scope.members = data.members;
          $scope.priorities = data.priorities;
          $scope.tags = data.tags;
        console.log (":::>",data)
       }
    });


  // MEMBERS
  $scope.filterActivityOptions = {
      filterText: ''
  };

 
  $scope.$watch('searchMemberModel', function(newText){
        $scope.filterActivityOptions.filterText = newText;
  })
  
  $scope.gridMemberOptions = { data: 'members', 
     selectedItems: $scope.memberSelections,
     multiSelect: false,
     filterOptions: $scope.filterActivityOptions,
     columnDefs: [{field:'name', displayName:'Member Name'}, 
                  {field:'surname', displayName:'Surname'}, 
                  {field:'displayedName', displayName:'Displaye Name'}],

     afterSelectionChange: function(rowItem, event) {
        //$location.url ("/about/" +  rowItem.entity.id)
        $scope.memberName = rowItem.entity.name
        $scope.memberSurName = rowItem.entity.surname
        $scope.memberDisplayedName = rowItem.entity.displayedName
        $scope.memberEmail = rowItem.entity.mail
        $scope.memberPass = rowItem.entity.pass
     }/*,
     ngGridEventData: function() {
        console.log ("ngGridEventData")
     } */
  };


  // PRIORITY 
  $scope.gridPriorityOptions = { data: 'priorities', 
     columnDefs: [{field:'label', displayName:'Priority Label'}],
     multiSelect: false,

     afterSelectionChange: function(rowItem, event) {
        //$location.url ("/about/" +  rowItem.entity.id)
        $scope.priorityName = rowItem.entity.label
     }/*,
     ngGridEventData: function() {
        console.log ("ngGridEventData")
     } */
  };

  // TAGS 
  $scope.gridTagsOptions = { data: 'tags', 
     multiSelect: false,
     columnDefs: [{field:'label', displayName:'Priority Label'}],


     afterSelectionChange: function(rowItem, event) {
        //$location.url ("/about/" +  rowItem.entity.id)
        console.log ("event", rowItem)
        $scope.tagRowIndex = rowItem.rowIndex
        $scope.selectedTagLabel = rowItem.entity.label;
        $scope.selectedTag = rowItem.entity;
     }/*,
     ngGridEventData: function() {
        console.log ("ngGridEventData")
     } */
  };

  $scope.addNewTag = function () {
    console.log ("DQW", $scope.selectedTag, $scope.gridTagsOptions)
    
    $scope.gridTagsOptions.selectRow($scope.tagRowIndex, false);
    $scope.selectedTagLabel = ""
    

  }

}


DashBoardCtrl.$inject = ['$scope', '$location', 
                         'DashBoardGetAll'];

function DashBoardCtrl($scope,  $location, DashBoardGetAll) {
  
    var chart1 = {};
    chart1.type = "AreaChart";
    chart1.displayed = false;
    chart1.cssStyle = "height:400px; width:100%";
    chart1.data = {"cols": [
        {id: "month", label: "Month", type: "string"},
        {id: "laptop-id", label: "General", type: "number"},
        {id: "desktop-id", label: "Design", type: "number"},
        {id: "server-id", label: "Prototypes", type: "number"}
    ], "rows": [
        {c: [
            {v: "January"},
            {v: 19, f: "2 comments, 4 thread, 12 files"},
            {v: 12, f: "7 comments, 1 thread, 4 files"},
            {v: 7, f: "7 comments"}
        ]},
        {c: [
            {v: "February"},
            {v: 13, f: "1 comments, 44 thread, 12 files"},
            {v: 1, f: "31 comments, 31 thread, 4 files"},
            {v: 1, f: "1 comments"}
        ]},
        {c: [
            {v: "March"},
            {v: 24, f: "21 comments, 44 thread, 12 files"},
            {v: 5, f: "431 comments, 31 thread, 4 files"},
            {v: 11, f: "51 comments"}

        ]}
    ]};

    chart1.options = {
        "isStacked": "true",
        "fill": 20,
        "displayExactValues": true,
        "vAxis": {
            "gridlines": {"count": 10}
        }
    };

    $scope.chart = chart1;




    $scope.mySelections = [];

    // Get recent activities
    DashBoardGetAll.get( { limit: 30},  function(data) {
       if (data.result.status == "ok")
       {
        $scope.recentActivities = data.activities;
        $scope.myTodo = data.myTodo;
        console.log (":::>",data)
       }
    });

    /*

    $scope.myData = [
      {Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 001},
      {Title: "bla bla bla", author: "TD", date: "12-mag - 5.12pm", id: 002 },
      {Title: "bla bla bla", author: "FF", date: "12-mag - 5.12pm", id: 003 },
      {Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 004 },
      {Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 005 },
      {Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 006 },
      {Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 007 },

    ];*/

  $scope.filterActivityOptions = {
      filterText: ''
  };

 
  $scope.$watch('searchActivityModel', function(newText){
        $scope.filterActivityOptions.filterText = newText;
  })
  
  $scope.gridOptions = { data: 'recentActivities', 
     selectedItems: $scope.mySelections,
     multiSelect: false,
     filterOptions: $scope.filterActivityOptions,
     columnDefs: [{field:'label', displayName:'Recent Activity'}, 
                  {field:'type', displayName:'Type'}, 
                  {field:'author', displayName:'Aut.', width: 50},
                  {field:'date', displayName:'Date'}],

     afterSelectionChange: function(rowItem, event) {
        console.log ("beforeSelectionChange", rowItem.entity)
        $location.url ("/about/" +  rowItem.entity.id)
     }/*,
     ngGridEventData: function() {
        console.log ("ngGridEventData")
     } */
  };




  
  $scope.filterTodoOptions = {
      filterText: ''
  };

  $scope.$watch('searchTodoModel', function(newText){
        $scope.filterTodoOptions.filterText = newText;
  })


  $scope.gridTodoOptions = { data: 'myTodo', 
         selectedItems: $scope.myTodoSelections,
         filterOptions: $scope.filterTodoOptions,
         multiSelect: false,
         columnDefs: [{field:'title', displayName:'MyTodo'},
                      {field:'priority', displayName:'priority', width: 80}, 
                      {field:'attach', displayName:'Alleg.', width: 70}, 
                      {field:'comments', displayName:'Comm.', width: 70}
                      ],

         afterSelectionChange: function(rowItem, event) {
            console.log ("beforeSelectionChange", rowItem.entity)
            $location.url ("/about/" +  rowItem.entity.id)
         }/*,
         ngGridEventData: function() {
            console.log ("ngGridEventData")
         } */
      };






  }



MyCtrl.$inject = ['$scope', '$location', 'BlogGetRecentActivities'];

function MyCtrl($scope,  $location, BlogGetRecentActivities) {
	

    $scope.mySelections = [];

    // Get recent activities
    BlogGetRecentActivities.get( { limit: 15},  function(data) {
         if (data.result.status == "ok")
         {
          $scope.recentActivities = data.activities;
        
         }
      });

    /*

    $scope.myData = [
    	{Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 001},
    	{Title: "bla bla bla", author: "TD", date: "12-mag - 5.12pm", id: 002 },
    	{Title: "bla bla bla", author: "FF", date: "12-mag - 5.12pm", id: 003 },
    	{Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 004 },
    	{Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 005 },
    	{Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 006 },
    	{Title: "bla bla bla", author: "FB", date: "12-mag - 5.12pm", id: 007 },

    ];*/
    $scope.gridOptions = { data: 'recentActivities', 
                           selectedItems: $scope.mySelections,
                           multiSelect: false,
                           columnDefs: [{field:'label', displayName:'Title'}, 
                                        {field:'author', displayName:'Aut.', width: 50},
                                        {field:'date', displayName:'Date'}],

                           afterSelectionChange: function(rowItem, event) {
                              console.log ("beforeSelectionChange", rowItem.entity)
                              $location.url ("/about/" +  rowItem.entity.id)
                           }/*,
                           ngGridEventData: function() {
                              console.log ("ngGridEventData")
                           } */
                        };
    // you can also specify data as: $scope.myOptions = { data: $scope.myData }. 
    // However, updates to the underlying data will not be reflected in the grid

    /*$scope.$on('afterSelectionChange', function(rowItem, event){
        //$scope.gridOptions.selectRow(0, true);
        console.log ("afterSelectionChange")
    });

    $scope.$on('beforeSelectionChange', function(rowItem, event){
        //$scope.gridOptions.selectRow(0, true);
        console.log ("beforeSelectionChange")
    });

    $scope.$on('ngGridEventData', function(){
        console.log ("ngGridEventData")
    });*/

};



function addCommentCtrl($scope) {


  $scope.isCodePanelHidden = true;

  /* $scope.language = "javascript"*/
  $scope.listCode = [{
  			    name: 'HTML',
  			    value: "html"},
  			{
  			    name: 'Javascript',
  			    value: 'javascript'
  			}]

  $scope.language = $scope.listCode[1];

 

}


function DropdownCtrl($scope) {
  $scope.items = [
    {label: "Add Post", url:"#/addNewPost"},
   /* {label: "Read Posts", url:"#/about"},    */
    {label: "ToDo List", url:"#/todos"},
    {label: "Time Tracking", url:"#/time_tracking"},
    {label: "DashBoard", url:"#/dashboard"},
    {label: "Settings", url:"#/settings"},
    {label: "Coming Soon", url:"#/coming"},
  ];
}


function ProjectsMenuCtrl($scope) {
  $scope.items = [
    {label: "Zeus - Digital Lighiting", url:"#/dashboard"},
    {label: "Permasteelisa Universe", url:"#/dashboard"},    
    {label: "SpaziOpportunità", url:"#/dashboard"}
    
    
  ];
}



function NotifyToCtrl($scope) {
  
$scope.checkModel = {
    left: false,
    middle: true,
    right: false,
    four: false,
  };

}

function AccordionDemoCtrl($scope) {
  $scope.oneAtATime = true;

  $scope.groups = [
    {
      title: "Nota 2",
      content: "Dynamic Group Body - 1"
    },
    {
      title: "Nota 3",
      content: "Dynamic Group Body - 2"
    }
  ];

  $scope.items = ['Item 1', 'Item 2', 'Item 3'];

  $scope.addItem = function() {
    var newItemNo = $scope.items.length + 1;
    $scope.items.push('Item ' + newItemNo);
  };
}


function CommentsCtrl($scope) {
	$scope.dynamicTooltip = "Hello, World!";
  $scope.dynamicTooltipText = "dynamic";
  $scope.htmlTooltip = "I've been made <b>bold</b>!";



}

